package client

import (
	"github.com/cloudwego/hertz/pkg/app/client"
	"github.com/cloudwego/hertz/pkg/app/middlewares/client/sd"
	"github.com/cloudwego/hertz/pkg/common/hlog"
	"github.com/hertz-contrib/registry/eureka"
)

var (
	Cli *client.Client
	err error
)

func Init() {
	// 创建 Hertz 客户端
	Cli, err = client.NewClient()
	if err != nil {
		hlog.Fatal(err)
		return
	}
	// 初始化 Eureka 发现客户端
	rClient := eureka.NewEurekaResolver([]string{"http://127.0.0.1:8761/eureka"})

	Cli.Use(sd.Discovery(rClient))
}
